package com.shura.ssm.controller.User;

import com.shura.ssm.common.entity.User;
import com.shura.ssm.controller.AbstractController;
import com.shura.ssm.service.UserService.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * UserController
 * Created by shura
 * Date：2017/9/3
 * Time：21:30
 */
@Controller
@RequestMapping("")
public class UserController extends AbstractController{

    @Autowired
    private UserService userService;

    @RequestMapping("/index")
    public String toIndex(HttpServletRequest request, Model model){
        int userId = Integer.parseInt(request.getParameter("id"));
        User user = new User();
        try{
        user = this.userService.queryById(userId);
        }catch(Exception e){
            return e.getMessage();
        }
        model.addAttribute("user",user.getUserName());
        return "index";
    }

}
